package com.framework.modules.sys.controller;


import com.framework.entity.sys.SysActive;
import com.framework.exception.util.RespResult;
import com.framework.page.PageUtils;
import com.framework.service.ActiveService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/sys/sysactive")
public class SysActiveController extends AbstractController {
    @Autowired
    private ActiveService activeService ;

    @RequestMapping("/list")
    @RequiresPermissions("sys:sysactive:list")
    public RespResult List(){

        List<SysActive> list = activeService.queryActiveList(getUser().getDeptId());
        return RespResult.ok().put("page",list);
    }
    @RequestMapping("/typelist")
    public RespResult typelist(@RequestParam Map<String,Object> params){
        PageUtils page = activeService.queryActiveTypeList(params);
        return RespResult.ok().put("page",page);
    }
    @RequestMapping("/insert")
    public RespResult insertActive(@RequestBody SysActive sysActive){
        activeService.insertActiveType(sysActive);
        return RespResult.ok();
    }
    @RequestMapping("/querybyid")
    public RespResult queryById(@RequestParam Long activeId){
        return RespResult.ok().put("active",activeService.queryActiveById(activeId));
    }
    @RequestMapping("/updatebyid")
    public RespResult updateByid(@RequestBody SysActive sysActive){
        activeService.updateActiveById(sysActive);
        return RespResult.ok();
    }
}
